/**
 * This code is part of the Bumpslide Library by David Knape
 * http://bumpslide.com/
 * 
 * Copyright (c) 2006, 2007, 2008 by Bumpslide, Inc.
 * 
 * Released under the open-source MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * see LICENSE.txt for full license terms
 */
 package {
	import com.bumpslide.events.UIEvent;	import com.bumpslide.tween.FTween;	import com.bumpslide.ui.Applet;	import com.bumpslide.ui.ScrollPanel;	import com.bumpslide.ui.TextPanel;	import com.bumpslide.util.LoremIpsum;		import flash.filters.BlurFilter;	
	/**
	 * Example of motion blur applied to tweened scroll panel
	 *  
	 * @mxmlc -sp+=../../classes -default-frame-rate=31 -debug=true
	 * @author David Knape
	 */
	public class Demo_06_BlurScroller extends Applet {

		private var panel:TextPanel;

		override protected function addChildren():void {			
			// create text panel and fill with lorem ipsum text
			panel = new TextPanel();
			panel.move(10, 10);	
			panel.text = LoremIpsum.TEXT + "\n\n" + LoremIpsum.TEXT;
			addChild(panel);
			
			// enable tweening and listen for tween update events
			panel.tweenEnabled = true;
			panel.addEventListener( ScrollPanel.EVENT_TWEENED, handleScrollPanelTween );
		}
		
		private function handleScrollPanelTween(event:UIEvent):void {
			var tween:FTween = event.data as FTween;
			var blur_y:Number = Math.abs( tween.velocity ) * .5; 
			panel.content.filters = [ new BlurFilter( 0, blur_y, 3) ];
		}

		// on stage resize, update panel size
		override protected function draw():void {
			panel.setSize(width - 20, height - 20);
		}
	}
}
